CD=cd
CP=cp
GCC=gcc
CPP=g++
BJAM=b2
SED=sed
PWD=$(shell pwd)

socks:
	$(MAKE) -C ./sine/apps/

hip:
	$(MAKE) -C ./transport/openhip/

mip6d:
	$(MAKE) -C ./transport/umip/

mih:
	$(CD) ./transport/mih/odtone; $(BJAM) -q linkflags=-lpthread

lm: ./sine/middleware/locationMgr/locationMgr.cpp
	$(CPP) ./sine/middleware/locationMgr/locationMgr.cpp -o ./sine/middleware/locationMgr/lm -lpthread 

all: socks hip mip6d mih lm

install:
	./sine/apps/kill_sined
	$(MAKE) -C ./transport/openhip/ install
	hitgen
	$(MAKE) -C ./transport/umip/ install
	$(CP) ./transport/umip/mip6d.conf /usr/local/etc/mip6d.conf
	#$(CP) ./transport/mih/mih /usr/local/sbin/mih
	$(SED) 's/SINE_ROOT=/SINE_ROOT=$(subst /,\/,$(PWD))/' <./transport/mih/mih >/usr/local/sbin/mih
	chmod +x /usr/local/sbin/mih
	$(CP) ./sine/middleware/locationMgr/lm /usr/local/sbin/lm
	$(CP) ./sine/apps/sined /usr/local/sbin/sined
	$(CP) ./sine/apps/kill_sined /usr/local/sbin/kill_sined
	$(CP) ./sine/sine_policy.conf /etc/sine_policy.conf
	$(CP) ./sine/srelay.conf /etc/srelay.conf

clean:
	$(MAKE) -C ./sine/apps/ clean
	$(MAKE) -C ./transport/openhip/ clean
	$(MAKE) -C ./transport/umip/ clean
	$(CD) ./transport/mih/odtone; $(BJAM) clean
